module.exports = function ($resource, $state, $http, $modal, FileUploader, toaster) {

	return {

		restrict: 'AE',
		template: require('../views/createpeople.html'),
		replace: true,
		scope: {
      'what': '=',
			'saleobj': '=',
			'funobj': '=',
			'baseinfo': '=',
			'util': '=',
		},
		link: function (scope, elements, attrs, modal) {
      console.log(scope.what);
      console.log("sa");
      console.log(scope.saleobj);
      scope.objs = []
      var para = {
        'tcode' : scope.saleobj.tourgroup_code,
        'list' : scope.objs
      }
      scope.save = function () {
        // alert("看好了~我要保存了！");
        $resource('/api/ac/ggc/tourGroupAfter/createTGroupPeo', {}, {}).save(para,function (res) {
          if(res.errcode !== 0){
            toaster.error({ title: "提示", body: res.errmsg });
          }else{
            toaster.success({title: "提示", body: "创建成功！"});
            $modalInstance.close();
          }
        });
      }
      scope.addp = function() {
        
        scope.objs.push({
          name : '',
          tel : '',
          people_idcard : '',
          people_adress : '',
        })
        scope.remove = function (index) {
          scope.objs.splice(index, 1);
      }
    }

    }
    }
}